package msmstacmp

import (
	"gitee.com/ymofen/gobase"
	"gitee.com/ymofen/golog"
	"github.com/spf13/cobra"
	"time"
)

func init() {
	gobase.ArgFuncRegister("vrsstacmp", gobase.ArgFuncOption{Catalog: "corbaRoot", Func: func(args string, tag interface{}) (val interface{}, err error) {
		var cbrunner CorbaRunner
		var addCorbaTask = &cobra.Command{
			Use: "vrsstacmp",
			Run: func(cmd *cobra.Command, args []string) {
				golog.Infof("subConf:%s", cbrunner.SubConf)
				golog.Infof("pubConf:%s", cbrunner.PubConf)
				cbrunner.Run()
				gobase.HookExitSignalAndInterval(0, time.Second*10, func() {

				})
			},
		}
		addCorbaTask.Flags().StringVarP(&cbrunner.SubConf, "subConf", "i", "conntype=datafrom&connstr=", "")
		addCorbaTask.Flags().StringVarP(&cbrunner.PubConf, "pubConf", "o", "conntype=caster&connstr=", "")
		return addCorbaTask, nil
	}})

}

type CorbaRunner struct {
	Id      string
	SubConf string
	PubConf string
}

func (this *CorbaRunner) Run() error {
	if len(this.Id) == 0 {
		this.Id = "SPCpy"
	}

	return nil
}
